home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 426-450 / disk_429 / dr / forevery_and_whichever < prev    next >
Text File  |  1992-05-06  |  3KB  |  51 lines

  1.  
  2.                            FOREVERY and WHICHEVER
  3.  
  4. These are two related small utilities.  Each takes a CLI command on its
  5. argument line, with a place marked in it with [] like in an alias.  Each
  6. reads its standard input (use redirection to send a file into it) and
  7. substitutes a line of the input file into the command at the point marked by
  8. [].  ForEvery executes the command once for every line in the input file,
  9. except blank lines or lines that make the command more than 255 characters
  10. long, and Whichever picks a single line of the input file at random and
  11. substitutes that into the command and executes it.
  12.  
  13. Generally the input file would be a list of filenames, one per line.  The
  14. command would do something with that file.  For instance you might want to
  15. mark some files as archived.  You'd put the list of files in a file called,
  16. for instance, T:arch, and give the command
  17.  
  18.    ForEvery < T:Arch Protect [] +a
  19.  
  20. Dr is a good program for generating lists of files one per line, using its -o
  21. option.  Rls by Donald Kindred works similarly.  The use I wrote Whichever
  22. for was so that I would never know what sound my computer would use for a
  23. beep after a reboot.  I put a list of IFF sound files into the file Bleeps,
  24. and include in my startup-sequence the command
  25.  
  26.    Whichever < Bleeps InstallBeep []
  27.  
  28. Whichever, unlike ForEvery, reads the entire input file into memory, so don't
  29. use too enormous a file.  In fact it cannot read more than 1000 lines.  Like
  30. ForEvery, it rejects any line that would make the command more than 255
  31. characters long.
  32.  
  33. One bad feature of ForEvery:  it would be nice if you could stop it with
  34. control-C or control-D, but when you redirect input the CLI makes the program
  35. unable to hear those signals!  I looked for a workaround but didn't find one.
  36. So this version of the program can't be stopped in the middle.
  37.  
  38. There is some preparation you should set up to get the best performance out
  39. of ForEvery, or for that matter out of any program that uses the DOS
  40. Execute() function.  Older versions of Execute() always loaded the Run
  41. program from disk every time.  Now that's no longer necessary, if the
  42. following conditions are met:  the Run program has been made resident, you
  43. are using 1.3 or newer ROM/Kickstart, and (if your ROM is 1.3) you have run
  44. the 1.3.2 version of SetPatch.  The 1.3.0 SetPatch won't do.  If you do not
  45. have 1.3.2, get it, or just get its SetPatch!  Many many programs will run
  46. quicker and easier.  It also helps to have L:Shell-Seg resident, if the
  47. command that is being fed to Execute() calls a program that is residentable.
  48.  
  49. ForEvery is pure (residentable), but Whichever is not.  Both are in the
  50. public domain, written by Paul Kienitz.
  51.